package org.yn.base.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.yn.base.config.RegisterNoticeRabbitmqConfig;
import org.yn.base.util.SMSUtils;
import org.yn.base.util.SendMailUtil;
import org.yn.user.dto.EmailDTO;
import org.yn.user.dto.SmsDTO;

@Configuration
public class UserRegisterRabbitMqListener {
    @Autowired
    SMSUtils smsUtils;

    @Autowired
    SendMailUtil sendMailUtil;

      //监听发送短信
    @RabbitListener(queues = RegisterNoticeRabbitmqConfig.QUEUE_INFORM_SMS)
    public void lisenserSendSms(SmsDTO dto){
        smsUtils.sendMessage(dto.getRecipient(), dto.getSmsCode());
    }

    //监听发送邮件
    @RabbitListener(queues = RegisterNoticeRabbitmqConfig.QUEUE_INFORM_EMAIL)
    public void lisenserSendSms(EmailDTO dto){
        sendMailUtil.sendHtmlMail("",dto.getRecipient(),dto.getSubject(),dto.getContent());
    }
}
